package com.zznode.client.wlanpolling.utils;

import com.zznode.client.wlanpolling.EnumRunMode;

public class WLanPollingUtils {
	public static final String SYSTEM_SETTING = "SYSTEM_SETTING";
	public static final String KEY_ADDRESS = "serverAddress";
	public static final String KEY_PORT = "port";
	public static final String KET_SAVEPASSWORD = "savepassword";
	
	
	public static final String USER_INFO = "USER_INFO";
	public static final String USERNAME = "USERNAME";
	public static final String PASSWORD = "PASSWORD";
	
//	public static final EnumRunMode RUN_MODE = EnumRunMode.DEBUG;
	public static final EnumRunMode RUN_MODE = EnumRunMode.RELEASE;
	public static final String DEFAULT_CHARSET = "UTF-8";
	public static final String DEFAULT_SERVEADDRESS = "http://211.137.32.193";
	public static final String DEFAULT_PORT = "4380";
	
	public static String serverAddress;
	public static String port;
	
	//public static final String DEBUG_WIFI = "00 24 B2 9D 4D C0";
	//public static final String DEBUG_WIFI = "00 14 D5 FD 45 03";
	public static final String DEBUG_WIFI = "00 14 D5 FD 44 0F";
	public static final String DEBUG_IP = "61.191.20.30";
	public static final double DEBUG_LONTITUE = 117.68639;
	public static final double DEBUG_LATITUDE = 32.53167;
	
	/**
	 * 用户身份验证接口db
	 */
	private final static String LOGIN_URL = "/liveinspecserver/phoneLogin.do";

	/**
	 * 根据设备Mac地址获取设备信息
	 * http://61.191.39.104:3389/liveinspecserver/getDevInfoByMac.do?apmac={apmac}
	 */
	private final static String DEVINFO_URL = "/liveinspecserver/getDevInfoByMac.do";
	

	/**
	 * 获取字典信息
	 * http://61.191.39.104:3389/liveinspecserver/getDictsById.do?dictTypeId=BNDICT_hotspotstatus
	 */
	private final static String DICTS_URL = "/liveinspecserver/getDictsById.do";
	
	/**
	 * 获取巡检计划
	 * http://61.191.39.104:3389/liveinspecserver/ listLiveInspecOnlineAp.do?onLineApInfo={apmac}&ssids=${ssid}
	 */
	private final static String PLAN_URL =  "/liveinspecserver/listLiveInspecOnlineAp.do";
	
	/**
	 * 更新巡检信息
	 * http://61.191.39.104:3389/liveinspecserver/commitTestMain.do?sysApMac=00 24 B2 9D 4D C0&参数2=***&******
	 */
	private final static String UPDATEPOLLING_URL = "/liveinspecserver/commitTestMain.do";
	
	/**
	 * 获取FTP信息
	 * http://61.191.39.104:3380/liveinspecserver/listPhoneFtp.do?UID=1111
	 */
	private final static String LISTPHONEFTP_URL = "/liveinspecserver/listPhoneFtp.do";
	
	/**
	 * 更新无线环境地址
	 */
	private final static String UPDATE_WIRELESSENV = "/liveinspecserver/CommitNearApInfo.do";
	
	//http://202.102.216.8:3389/liveinspecserver/getHotspotinfoByLonLat.do?lontitue=115.60778&latitude=33.15444&UID=1111
	/**
	 * 获取某个位置附近的热点信息
	 */
	private final static String GETHOTSOTINFO_URL = "/liveinspecserver/getHotspotinfoByLonLat.do"; 	
	
	/**
	 * 提交网站测速
	 */
	private final static String UPDATE_WEBSITERESULT = "/liveinspecserver/CommitTestRatio.do";
	
	/**
	 * 故障描述提交地址URL
	 */
	private final static String BREAKDOWN_URL = "/liveinspecserver/commitFaultReason.do";
	
	/**
	 * 资源补录
	 */
	private final static String COMMIT_RESOUCE_URL = "/liveinspecserver/commitResource.do";
	
	/**
	 * 无线环境信息
	 */
	private final static String WIRELESSINFO = "/liveinspecserver/getWirelessInfo.do";
	
	public static String getHotspotinfoByLonLatURL() {
		return getHostAddress() + GETHOTSOTINFO_URL;
	}
	
	public static String getLoginURL() {
		return getHostAddress() + LOGIN_URL;
	}
	
	public static String getDevInfoURL() {
		return getHostAddress() + DEVINFO_URL;
	}
	
	public static String getDictsURL() {
		return getHostAddress() + DICTS_URL;
	}
	
	public static String getPlanURL() {
		return getHostAddress() + PLAN_URL;
	}
	
	public static String getUpdatePollingURL() {
		return getHostAddress() + UPDATEPOLLING_URL;
	}
	
	public static String getListPhoneFtpUrl() {
		return getHostAddress() + LISTPHONEFTP_URL;
	}
	
	public static String getUpdateWirelessEnv() {
		return getHostAddress() + UPDATE_WIRELESSENV;
	}
	
	public static String getUpdateWebSiteResultURL() {
		return getHostAddress() + UPDATE_WEBSITERESULT;
	}
	
	public static String getBreakdownUrl() {
		return getHostAddress() + BREAKDOWN_URL;
	}

	public static String getCommitResourceUrl() {
		return getHostAddress() + COMMIT_RESOUCE_URL;
	}
	
	public static String getWirelessInfoURL() {
		return getHostAddress() + WIRELESSINFO;
	}
	
	private static String getHostAddress() {
		String host = serverAddress;
		if(host == null)host = DEFAULT_SERVEADDRESS;
		while(host != null && host.endsWith("/") && host.length() > 2) {
			host = host.substring(0, host.length() - 2);
		}
		
		if(port == null)port = DEFAULT_PORT;
		int realPort = Integer.parseInt(port);
		
		if(realPort != 80) {
			host += ":" + realPort;
		}
		
		return host;
	}
}


